package io.gitee.kotle.android


fun getFragmentStr(
        temp: BaseTemplate,
        packageName: String,
        classPath: String,
        className: String,
        bindingName: String,
        isNeedViewModel: Boolean,
): String {
    val firstChar = className.first()
    val classNameLowerCase = firstChar.toLowerCase() + className.trimStart(firstChar)

    return """
    package $classPath

    import android.os.Bundle
    import fragment.CompatBinding${temp.classTypeName}
    import ${packageName}.databinding.${bindingName}
    ${if (isNeedViewModel) "import androidx.fragment.app.viewModels" else ""}

    class ${className}${temp.classTypeName} : CompatBinding${temp.classTypeName}<${bindingName}>() {
      
        ${if (isNeedViewModel) "private val ${classNameLowerCase}ViewModel by viewModels<${className}ViewModel>()" else ""}

        override fun initUi(savedInstanceState: Bundle?) {
            super.initUi(savedInstanceState)
        }

        override fun initObserver() {
            super.initObserver()
        }

        override fun initData() {
            super.initData()
        }
    }
""".trimIndent()
}


fun getViewModelStr(
        classPath: String,
        className: String,
): String {
    return """
    package $classPath

    import viewmodel.CompatViewModel

    class ${className}ViewModel : CompatViewModel() {
    }
""".trimIndent()
}






